package com.itheima.arrayListTest;

import com.itheima.domain.Student;

import java.util.ArrayList;
import java.util.Scanner;

/**
 * @Author 王加鑫
 * @Date 2021/4/29 9:40
 * @Version 1.0
 * 初始集合
 */
public class Test1 {
    public static void main(String[] args) {
        ArrayList<Student> list = new ArrayList<>();
        Student student1 = getStudent();
        Student student2 = getStudent();;
        Student student3 = getStudent();;

        for (int i = 0; i <3 ; i++) {
            list.add(getStudent());

        }
//        list.add(0,student1);
//        list.add(student2);
//        list.add(student3);
        System.out.println(list);

    }

    public static Student getStudent(){
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入学生姓名:");
        String name = scanner.next();
        System.out.println("请输入学生年龄");
        int age = scanner.nextInt();
        Student student = new Student(name,age);
        return student;
    }
}
